# Maintainer: Lukas Fleischer <lfleischer@archlinux.org>
# Contributor: Andrea Scarpino <andrea@archlinux.org>
# Contributor: Paul Mattal <paul@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=ncftp
pkgver=3.2.6
pkgrel=4
pkgdesc="A set of free application programs implementing FTP"
url="https://www.ncftp.com/"
arch=('x86_64')
license=('custom')
depends=('ncurses')
makedepends=('inetutils')
source=("ftp://ftp.ncftp.com/ncftp/$pkgname-$pkgver-src.tar.xz"
        ncftp-reproducible.patch)
md5sums=('42d0f896d69a4d603ec097546444245f'
         'bf51aa93c785d366e19ccce78820da5a')

prepare() {
  cd "${pkgname}-${pkgver}"
  # Make ncftp reproducible by not compiling in the kernel version
  patch -Np1 -i "${srcdir}/ncftp-reproducible.patch"
}

build() {
  cd "${pkgname}-${pkgver}"

  CFLAGS+=' -fcommon' # https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common

  # FS#39211
  unset CPPFLAGS

  CPP=/usr/bin/cpp ./configure --prefix=/usr --sysconfdir=/etc
  make
}

package() {
  cd "${pkgname}-${pkgver}"

  install -d "${pkgdir}/usr/share"
  make prefix="${pkgdir}/usr" mandir="${pkgdir}/usr/share/man" install
  install -Dm644 doc/LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
}
